package com.kb5173.search.index.document;

import com.fasterxml.jackson.annotation.JsonTypeInfo;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.solr.client.solrj.beans.Field;
import org.springframework.data.annotation.Id;

import java.util.Date;

/**
 * solr索引基类
 *
 * @author Chengfei.Sun
 */
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.PROPERTY, property = "@class")
public abstract class BaseIndexDocument {
    public static final String ID_FIELD = "indexId";
    public static final String Document_TYPE_FIELD = "type";
    public static final String OPTION_TYPE_FIELD = "optionType";
    public static final String OPTION_TIME_FIELD = "optionTime";
    public static final String SOURCE_FIELD = "source";
    public static final String CREATE_TIME_FIELD = "createTime";

    /**
     * 索引ID
     * Solr中全局唯一
     */
    @Id
    @Field("indexId")
    private String indexId;

    /**
     * 文档类型
     */
    @Field("type")
    private String type;

    /**
     * 操作类型
     */
    @Field("optionType")
    private int optionType;

    /**
     * 操作时间
     */
    @Field("optionTime")
    private Date optionTime;

    /**
     * 来源
     */
    @Field("source")
    private String source;

    /**
     * 创建时间
     */
    @Field("createTime")
    private Date createTime;

    /**
     * 重载Entity类的toString()方法
     * 返回Entity类所有属性值
     */
    @Override
    public String toString() {
        return ToStringBuilder.reflectionToString(this);
    }

    public String getIndexId() {
        return indexId;
    }

    public void setIndexId(String indexId) {
        this.indexId = indexId;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public int getOptionType() {
        return optionType;
    }

    public void setOptionType(int optionType) {
        this.optionType = optionType;
    }

    public Date getOptionTime() {
        return optionTime;
    }

    public void setOptionTime(Date optionTime) {
        this.optionTime = optionTime;
    }

    public String getSource() {
        return source;
    }

    public void setSource(String source) {
        this.source = source;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}
